//
//  ZYVisitorImp.m
//  DesignMode
//
//  Created by wangzhipan on 2024/12/9.
//

#import "ZYVisitorImp.h"

@implementation ZYVisitor1

- (void)operatorOneForElementA:(id<IElement>)element
{
    NSLog(@"Visitor1 is processing One For ElementA");
}
- (void)operatorTwoForElementA:(id<IElement>)element
{
    NSLog(@"Visitor1 is processing Two For ElementA");
}

- (void)operatorOneForElementB:(id<IElement>)element
{
    NSLog(@"Visitor1 is processing One For ElementB");
}

- (void)operatorTwoForElementB:(id<IElement>)element
{
    NSLog(@"Visitor1 is processing Two For ElementB");
}

@end


@implementation ZYVisitor2

- (void)operatorOneForElementA:(id<IElement>)element
{
    NSLog(@"Visitor2 is processing One For ElementA");
}
- (void)operatorTwoForElementA:(id<IElement>)element
{
    NSLog(@"Visitor2 is processing Two For ElementA");
}

- (void)operatorOneForElementB:(id<IElement>)element
{
    NSLog(@"Visitor2 is processing One For ElementB");
}

- (void)operatorTwoForElementB:(id<IElement>)element
{
    NSLog(@"Visitor2 is processing Two For ElementB");
}

@end


@implementation ZYElementA

- (void)acceptVisitor:(id<IVisitor>)visitor
{
    [visitor operatorOneForElementA:self];
    [visitor operatorTwoForElementA:self];
}

@end


@implementation ZYElementB

- (void)acceptVisitor:(id<IVisitor>)visitor
{
    [visitor operatorOneForElementB:self];
    [visitor operatorTwoForElementB:self];
}

@end


@implementation ZYVisitorMainPage

- (void)main
{
    id<IVisitor>visitor = [[ZYVisitor1 alloc] init];
    
    id<IElement>elementA = [[ZYElementA alloc] init];
    
    id<IElement>elementB = [[ZYElementB alloc] init];
    
    [elementA acceptVisitor:visitor];
    [elementB acceptVisitor:visitor];
}

@end
